package com.baidu.infinity.ui.fragment

import android.os.Bundle
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.baidu.infinity.R
import com.baidu.infinity.databinding.FragmentPicLoginBinding
import com.baidu.infinity.db.User
import com.baidu.infinity.ui.base.BaseFragment
import com.baidu.infinity.viewmodel.UserViewModel

class PicLoginFragment : BaseFragment<FragmentPicLoginBinding>(){
    val userViewModel: UserViewModel by activityViewModels()
    override fun initUI(savedInstanceState: Bundle?) {
        super.initUI(savedInstanceState)
        mBinding.touchUnlockView.addPicPathFinishedListener{
            if(it == userViewModel.currentUser?.picPassword){
                findNavController().navigate(R.id.action_picLoginFragment_to_homeFragment)
                return@addPicPathFinishedListener true
            }else{
                mBinding.touchUnlockView.showError()
                return@addPicPathFinishedListener false
            }

        }
    }
}